<style scoped lang="less">
@c-primary: #3399ff;
.container {
  background: white;
  min-height: 100vh;
  .logo-seach {
    background-repeat: no-repeat;
    background-size: cover;
    height: 25vh;
    padding: 15px 10px;
    font-size: 12px;
    overflow: hidden;
    position: relative;
    &__bg {
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      width: 100%;
      height: 100%;
    }
    &__content {
      position: absolute;
      left: 25px;
    }
  }
  .logo {
    &-area {
      height: 12vh;
      display: flex;
      align-items: center;
      justify-content: center;
      overflow: hidden;
      &-pic {
        width: 42px;
        height: 33px;
        overflow: hidden;
      }
      &-describe {
        font-family: '微软雅黑';
        margin-left: 5px;
        font-size: 30px;
        color: #fff;
      }
    }
  }
}
.search {
  &-item {
    margin-top: 1px;
    margin-bottom: 10px;
    padding: 10px;
    font-size: 16px;
    &__icon {
      width: 20px;
      height: 20px;
      margin-right: 4px;
      background: pink;
    }
    &__title {
      flex: 1;
    }
    &__status {
      border: 1px solid @c-primary;
      border-radius: 4px;
      padding: 2px 6px;
      color: @c-primary;
      font-size: 12px;
    }
    &__grid {
      flex: 1;
      text-align: center;
      font-size: 14px;
      &-top {
        margin-top: 10px;
        color: #666;
      }
      &-txt {
        margin-top: 8px;
      }
    }
  }
  &-hot {
    &-list {
      padding: 0px 12px;
      &__item {
        font-size: 14px;
        position: relative;
        &__iconhot {
          width: 32px;
          height: 32px;
          position: absolute;
          top: 0px;
          right: 0;
        }
      }
      &__name,
      &__legal,
      &__types {
        margin: 5px 0px;
        font-size: 12px;
      }
      &__name {
        font-size: 14px;
        font-weight: bold;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }
    }
  }
}
.weui-search-bar {
  background-color: initial;
  border: none;
  &__form {
    border-top-right-radius: 0px;
    border-bottom-right-radius: 0px;
    box-shadow: 0 0 1px 0.1px #fff;
  }
  .weui-icon-search {
    &_in-box {
      top: 25rpx;
    }
    &_clear {
      top: 25rpx;
      position: absolute;
      right: 5px;
    }
  }
  &__input {
    height: 80rpx;
    line-height: 80rpx;
    font-size: 14px;
    padding-left: 10px;
  }
  &__btn {
    border-top-right-radius: 4px;
    border-bottom-right-radius: 4px;
    background: @c-primary;
    border: 1px solid @c-primary;
    color: white;
    height: 40px;
    line-height: 40px;
    width: 80px;
    text-align: center;
    font-size: 16px;
    box-shadow: 0 0 1px 0.1px #fff;
  }
}
.search-fixation {
  font-size: 12px;
  text-align: center;
  overflow: hidden;
  padding: 30rpx 0 20rpx;
  &__item {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
  }
  &-pic {
    width: 32px;
    height: 32px;
  }
  &-icon {
    width: 32px;
    height: 32px;
    font-size: 30px;
  }
  &-des {
    margin: 3px auto;
  }
}
.weui-loadmore {
  &__tips {
    position: relative;
    top: -0.7em;
    padding: 0 0.55em;
    background-color: #ffffff;
    color: #808080;
  }
}
.weui {
  &-grids {
    border: none;
    overflow: hidden;
    padding: 0 10px;
  }
  &-grid {
    // width: 50%;
    // padding: 10rpx 20rpx;
    // color:#666;
    width: 48%;
    padding: 10rpx 20rpx;
    color: #666;
    font-size: 24rpx;
    border: 1px solid #eaeaea;
    margin: 3px;
    border-radius: 5px;
  }
  &-loadmore {
    margin: 1em auto;
    line-height: 1.2em;
    &_line {
      margin-top: 1.2em;
    }
  }
}
</style>

<template>
  <section class="container">
    <div class="logo-seach">
      <img class="logo-seach__bg" src="/static/images/banner.jpg" alt="">
      <div class="logo-seach__content">
        <!--logo-->
        <div class="logo-area">
          <img class="logo-area-pic" src="/static/images/logo.png" alt="企数查">
          <div class="logo-area-describe">企数查</div>
        </div>
        <!-- search form -->
        <div class="weui-search-bar">
          <div class="weui-search-bar__form">
            <div class="weui-search-bar__box">
              <icon class="weui-icon-search_in-box" type="search" size="14"></icon>
              <input type="text" class="weui-search-bar__input" placeholder="请输入公司名/人名等关键词！" v-model="searchValue" confirm-type="done" @confirm="check" />
              <div class="weui-icon-clear" v-if="searchValue.length > 0" @click="clearInput">
                <icon class="weui-icon-search_clear" type="clear" size="14"></icon>
              </div>
            </div>
          </div>
          <div class="weui-search-bar__btn" @click="check">查询</div>
        </div>
      </div>

    </div>
    <!--fixation search-->
    <div class="weui-flex search-fixation">
      <div v-for="(item,index) in items" :key="index" class="weui-flex__item">
        <!-- <navigator :url="item.url" class="placeholder search-fixation__item" hover-class=""> -->
        <div class="placeholder search-fixation__item" hover-class="">
          <i :class="['search-fixation-icon','iconfont',item.icon]" />
          <!-- <img :src="item.img" class="search-fixation-pic"> -->
          <div class="search-fixation-des">{{item.name}}</div>
        </div>
      </div>
    </div>
    <!--hot search-->
    <div class="search-hot">
      <div class="weui-loadmore weui-loadmore_line">
        <span class="weui-loadmore__tips">热门搜索</span>
      </div>
      <div class="weui-grids">
        <div v-for="(item,index) in lists" :key="index" @click="itemClick(item)" class="weui-grid search-hot-list__item" hover-class="">
          <p class="search-hot-list__name" :title="item.name">{{item.name}}</p>
          <p class="search-hot-list__types">行业：{{item.types}}</p>
          <p class="search-hot-list__legal">法人：{{item.legal}}</p>
          <img :src="item.ishot ? iconHotUrl : ''" class="search-hot-list__item__iconhot">
        </div>
      </div>
    </div>
    <!-- 加载组件 -->
    <load></load>

    <!-- 分享按钮 -->
    <button class="share" open-type='share'>
      <i class="iconfont icon-plus-share"></i>
    </button>
  </section>
</template>

<script>
const items = [
  {
    img: '/static/images/qy.png',
    icon: 'icon-shuiwukaipiao',
    name: '税号查询',
    url: '/pages/search/main?id=1'
  },
  {
    img: '/static/images/qy.png',
    icon: 'icon-qiye',
    name: '企业名称',
    url: '/pages/search/main?id=2'
  },
  {
    img: '/static/images/qy.png',
    icon: 'icon-gudongxinxi',
    name: '股东高管',
    url: '/pages/search/main?id=3'
  },
  {
    img: '/static/images/qy.png',
    icon: 'icon-iconfontdizhi',
    name: '地址电话',
    url: '/pages/search/main?id=4'
  }
];
const lists = [
  {
    name: '万科企业股份有限公司',
    legal: '王石',
    types: '房地产',
    url: '/pages/search/main?searchvalue=万科企业股份有限公司',
    ishot: true
  },
  {
    name: '百度网讯科技有限公司',
    legal: '李彦宏',
    types: '互联网',
    url: '/pages/search/main?searchvalue=百度网讯科技有限公司',
    ishot: true
  },
  {
    name: '中国银行股份有限公司',
    legal: '田国力',
    types: '商务服务业',
    url: '/pages/search/main?searchvalue=中国银行股份有限公司'
  },
  {
    name: '华为技术有限公司',
    legal: '孙亚芳',
    types: '电信',
    url: '/pages/search/main?searchvalue=华为技术有限公司'
  }
];
export default {
  data() {
    return {
      active: 0,
      items,
      lists,
      searchValue: '',
      iconHotUrl: '/static/images/hot.png'
    };
  },
  created() {
    this.$store.commit('setUserInfo', null);
  },
  async onShow() {
    this.init();
    // this.getToken();
    // wx.showShareMenu({
    //   withShareTicket: true
    // });
    // console.log(1);

    // const url = '/app/getTreeMap';
    // const params = {
    //   unique: 'ed62f8e3abc5c548a381ecede999061a'
    // };
    // console.log(2);

    // const { status, message, result } = await this.$http.get(url, params);
    // console.log(result);
  },
  // onShareAppMessage: function() {
  //   return {
  //     title: '自定义分享标题',
  //     path: '/pages/company/main?unique=576c21e3468a6b178bbf291e4820e896'
  //   };
  // },
  methods: {
    init() {
      this.searchValue = '';
    },
    clearInput() {
      this.searchValue = '';
    },
    check() {
      this.$store.commit('setSearchValue', this.searchValue);
      this.$router.push('/pages/search/main');
    },
    itemClick(item) {
      this.searchValue = item.name;
      this.check();
    },
    async getToken() {
      // 获取授权信息
      let token = this.$store.state.token;
      if (token) {
        return;
      }
      const url = '/getToken';
      const res = await this.$http.get(url);
      if (res.status != 200) {
        wx.showToast({
          title: res.message || '获取失败！',
          icon: 'none',
          duration: 1000,
          mask: true
        });
        return;
      }
      this.$store.commit('setToken', res.result.sessionToken);
    }
  }
};
</script>
